import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {EntityService} from '../../../services/entity.service';
import {HandleParams} from '../../../utils';

@Component({
  selector: 'app-base-list',
  templateUrl: './base-list.component.html',
  styleUrls: ['./base-list.component.css']
})
export class BaseListComponent implements OnInit {

  arrYesNo: any[];
  constructor(
    private entityService: EntityService,
  ) {}
  ngOnInit() {
    console.log(this.entityService.test);

  }
  loadLazy(event) {
    if (this.pager.pageSize !== event.rows) {
      this.pager.pageSize = event.rows;
    }
    this.pager.first = event.first ;
    this.entityService.loadPage();
  }

  btnClick(btn, item?) {
    this.entityService.btnClick(btn, item);
  }
  tableRefresh() {
    let params = this.entityService.params;
    let item = HandleParams(params, this.entityService.pageParams);
    this.entityService.btnClick('refresh', item);
  }

  get model(){
    return this.entityService.pageData.list;
  }
  get pager(){
    return this.model.pager;
  }
  get buttons(){
    return this.entityService.buttons;
  }
  get dictionaries(){
    return this.entityService.dictionaries;
  }
}
